package com.example.day03homework.Servlet;

import com.example.day03homework.DAO.UserList;
import com.example.day03homework.POJO.User;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;


/*获取新闻列表*/
public class ListServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<User> listUser = new ArrayList<User>();
        UserList user = new UserList();
        try {
            listUser = user.getUser();
            req.setAttribute("list", listUser);
            req.getRequestDispatcher("/list.jsp").forward(req, resp);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doGet(req, resp);

    }
    }

